package com.surfilter.code.gen.tool;

import java.io.File;
import java.util.ArrayList;
import java.util.Iterator;

import org.dom4j.Document;
import org.dom4j.Element;
import org.dom4j.io.SAXReader;

public class TaskTools {
	
	public static Document getDocument(){
		SAXReader saxReader = new SAXReader();
		Document document = null;
		try {
			document = saxReader.read(new File("build/genCode.xml"));
		} catch (Exception e) {
			e.printStackTrace();
			System.out.println("xml文件路径错误");
		}
		return document;
	}
	
	
	public static ArrayList<String> getProjectNames(){
		
		ArrayList<String> arr = new ArrayList<String>();
		Document document = getDocument();
		Element root = document.getRootElement();
		//Element project = root.element("project");
		for(Iterator i = root.elementIterator("project");i.hasNext();) {
			Element ele = (Element)i.next();
			arr.add(ele.attribute("projectName").getText());
		}
		return arr;
		
	}
}
